]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
ibus-candidate-popup: Scale coordinates from IBus
authorJonas Ådahl <jadahl@gmail.com>
Thu, 29 Aug 2024 13:26:39 +0000 (15:26 +0200)
committerMarge Bot <marge-bot@gnome.org>
Fri, 30 Aug 2024 20:14:55 +0000 (20:14 +0000)
The coordinates are effectively in the windowing system coordinate
space, which when scaling Xwayland, we need to scale these. Do this with
the Meta.Window.protocol_to_stage() function on the focused window,
which handles it correctly for the corresponding windowing system and
configuration.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3458>

js/ui/ibusCandidatePopup.js

index f0f4f1a368ad8cf2b6820372ab4487fee05d4c89..5e9ac853f61ed77f0f741b73a855ce5e0eb778fb 100644 (file)
@@ -1,6 +1,7 @@
 import Clutter from 'gi://Clutter';
 import GObject from 'gi://GObject';
 import IBus from 'gi://IBus';
+import Mtk from 'gi://Mtk';
 import St from 'gi://St';
 
 import * as BoxPointer from './boxpointer.js';
@@ -203,14 +204,29 @@ class IbusCandidatePopup extends BoxPointer.BoxPointer {
             return;
 
         panelService.connect('set-cursor-location', (ps, x, y, w, h) => {
-            this._setDummyCursorGeometry(x, y, w, h);
+            const focusWindow = global.display.focus_window;
+            let rect = new Mtk.Rectangle({x, y, width: w, height: h});
+            if (!global.stage.key_focus && focusWindow)
+                rect = focusWindow.protocol_to_stage_rect(rect);
+            this._setDummyCursorGeometry(
+                rect.x,
+                rect.y,
+                rect.width,
+                rect.height);
         });
         try {
             panelService.connect('set-cursor-location-relative', (ps, x, y, w, h) => {
-                if (!global.display.focus_window)
+                const focusWindow = global.display.focus_window;
+                if (!focusWindow)
                     return;
-                let window = global.display.focus_window.get_compositor_private();
-                this._setDummyCursorGeometry(window.x + x, window.y + y, w, h);
+                let rect = new Mtk.Rectangle({x, y, width: w, height: h});
+                rect = focusWindow.protocol_to_stage_rect(rect);
+                const windowActor = focusWindow.get_compositor_private();
+                this._setDummyCursorGeometry(
+                    windowActor.x + rect.x,
+                    windowActor.y + rect.y,
+                    rect.w,
+                    rect.h);
             });
         } catch (e) {
             // Only recent IBus versions have support for this signal